Data and classificaiton processes used
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
all libraries used
import numpy as np
import pandas as pd
import statsmodels.api as sm
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.preprocessing import scale, StandardScaler
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
from sklearn.linear_model import LogisticRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.neural_network import MLPClassifier
from sklearn.tree import DecisionTreeClassifier
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import GradientBoostingClassifier
import warnings
warnings.filterwarnings("ignore", category= DeprecationWarning)
warnings.filterwarnings("ignore", category= FutureWarning)
libraries used in this field
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
data.head()
| Pregnancies | Glucose | BloodPressure | SkinThickness | Insulin | BMI | DiabetesPedigreeFunction | Age | Outcome | |
|---|---|---|---|---|---|---|---|---|---|
| 0 | 6 | 148 | 72 | 35 | 0 | 33.6 | 0.627 | 50 | 1 |
| 1 | 1 | 85 | 66 | 29 | 0 | 26.6 | 0.351 | 31 | 0 |
| 2 | 8 | 183 | 64 | 0 | 0 | 23.3 | 0.672 | 32 | 1 |
| 3 | 1 | 89 | 66 | 23 | 94 | 28.1 | 0.167 | 21 | 0 |
| 4 | 0 | 137 | 40 | 35 | 168 | 43.1 | 2.288 | 33 | 1 |
data["Outcome"].value_counts()
Outcome 0 500 1 268 Name: count, dtype: int64
data.describe().T
| count | mean | std | min | 25% | 50% | 75% | max | |
|---|---|---|---|---|---|---|---|---|
| Pregnancies | 768.0 | 3.845052 | 3.369578 | 0.000 | 1.00000 | 3.0000 | 6.00000 | 17.00 |
| Glucose | 768.0 | 120.894531 | 31.972618 | 0.000 | 99.00000 | 117.0000 | 140.25000 | 199.00 |
| BloodPressure | 768.0 | 69.105469 | 19.355807 | 0.000 | 62.00000 | 72.0000 | 80.00000 | 122.00 |
| SkinThickness | 768.0 | 20.536458 | 15.952218 | 0.000 | 0.00000 | 23.0000 | 32.00000 | 99.00 |
| Insulin | 768.0 | 79.799479 | 115.244002 | 0.000 | 0.00000 | 30.5000 | 127.25000 | 846.00 |
| BMI | 768.0 | 31.992578 | 7.884160 | 0.000 | 27.30000 | 32.0000 | 36.60000 | 67.10 |
| DiabetesPedigreeFunction | 768.0 | 0.471876 | 0.331329 | 0.078 | 0.24375 | 0.3725 | 0.62625 | 2.42 |
| Age | 768.0 | 33.240885 | 11.760232 | 21.000 | 24.00000 | 29.0000 | 41.00000 | 81.00 |
| Outcome | 768.0 | 0.348958 | 0.476951 | 0.000 | 0.00000 | 0.0000 | 1.00000 | 1.00 |
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
y.head()
0 1 1 0 2 1 3 0 4 1 Name: Outcome, dtype: int64
x.head()
| Pregnancies | Glucose | BloodPressure | SkinThickness | Insulin | BMI | DiabetesPedigreeFunction | Age | |
|---|---|---|---|---|---|---|---|---|
| 0 | 6 | 148 | 72 | 35 | 0 | 33.6 | 0.627 | 50 |
| 1 | 1 | 85 | 66 | 29 | 0 | 26.6 | 0.351 | 31 |
| 2 | 8 | 183 | 64 | 0 | 0 | 23.3 | 0.672 | 32 |
| 3 | 1 | 89 | 66 | 23 | 94 | 28.1 | 0.167 | 21 |
| 4 | 0 | 137 | 40 | 35 | 168 | 43.1 | 2.288 | 33 |
loj_model = LogisticRegression(solver="liblinear").fit(x,y)
loj_model.intercept_
array([-5.88679617])
loj_model.coef_
array([[ 1.16994476e-01, 2.83733435e-02, -1.68981359e-02,
7.55145090e-04, -6.41407258e-04, 5.97201268e-02,
6.76128123e-01, 7.23498971e-03]])
loj_model.predict(x)[0:10]
array([1, 0, 1, 0, 1, 0, 0, 1, 1, 0], dtype=int64)
y[0:10]
0 1 1 0 2 1 3 0 4 1 5 0 6 1 7 0 8 1 9 1 Name: Outcome, dtype: int64
y_pred= loj_model.predict(x)
confusion_matrix(y,y_pred) #karmaşıklık matriksi
array([[448, 52],
[121, 147]], dtype=int64)
accuracy_score(y,y_pred) #doğruluk oranı
0.7747395833333334
print(classification_report(y,y_pred))
precision recall f1-score support
0 0.79 0.90 0.84 500
1 0.74 0.55 0.63 268
accuracy 0.77 768
macro avg 0.76 0.72 0.73 768
weighted avg 0.77 0.77 0.77 768
loj_model.predict_proba(x)[0:10]
array([[0.3505852 , 0.6494148 ],
[0.91692518, 0.08307482],
[0.22489628, 0.77510372],
[0.92127453, 0.07872547],
[0.16759435, 0.83240565],
[0.79886109, 0.20113891],
[0.8800353 , 0.1199647 ],
[0.27795677, 0.72204323],
[0.32053464, 0.67946536],
[0.92264521, 0.07735479]])
logit_roc_auc = roc_auc_score(y, loj_model.predict(x))
fpr, tpr, thresholds = roc_curve(y, loj_model.predict_proba(x) [:,1])
plt.figure()
plt.plot(fpr, tpr, label='AUC (area 1 %0.2f)' % logit_roc_auc)
plt.plot([0, 1], [0, 1],'r--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.title('Receiver operating characteristic')
plt.legend(loc="lower right")
plt.savefig('Log_ROC')
plt.show()
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
loj_model= LogisticRegression(solver= "liblinear").fit(x_train,y_train)
y_pred= loj_model.predict(x_test)
print(accuracy_score(y_test,y_pred))
0.7532467532467533
cross_val_score(loj_model, x_test, y_test, cv= 10).mean()
0.7704710144927536
libraries used in this field
from sklearn.neighbors import KNeighborsClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
knn_model= KNeighborsClassifier().fit(x_train,y_train)
knn_model
KNeighborsClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
KNeighborsClassifier()
y_pred= knn_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.6883116883116883
print(classification_report(y_test,y_pred))
precision recall f1-score support
0 0.77 0.75 0.76 151
1 0.55 0.56 0.56 80
accuracy 0.69 231
macro avg 0.66 0.66 0.66 231
weighted avg 0.69 0.69 0.69 231
knn= KNeighborsClassifier()
knn_params= {"n_neighbors":np.arange(1,50)}
knn_cv_model= GridSearchCV(knn,knn_params, cv=10).fit(x_train,y_train)
knn_cv_model.best_score_
0.748637316561845
knn_cv_model.best_params_
{'n_neighbors': 11}
knn_tuned = KNeighborsClassifier(n_neighbors= 11).fit(x_train,y_train)
y_pred= knn_tuned.predict(x_test)
accuracy_score(y_test, y_pred)
0.7316017316017316
knn_tuned.score(x_test,y_test) # kısa yol
0.7316017316017316
Purpose: to separate the two classes we have
libraries used in this field
from sklearn.svm import SVC
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
svm_model= SVC(kernel= "linear").fit(x_train,y_train)
svm_model
SVC(kernel='linear')In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
SVC(kernel='linear')
y_pred= svm_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7445887445887446
svm_params= {"C":np.arange(1,5),
"kernel":["linear","rbf"]}
svm= SVC()
svm_cv_model= GridSearchCV(svm,svm_params,cv=5,n_jobs=-1,verbose=2).fit(x_train,y_train)
Fitting 5 folds for each of 8 candidates, totalling 40 fits
svm_cv_model.best_score_
0.7839044652128765
svm_cv_model.best_params_
{'C': 2, 'kernel': 'linear'}
svm_tuned= SVC(C= 2, kernel= "linear").fit(x_train,y_train)
y_pred= svm_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7445887445887446
libraries used in this field
from sklearn.neural_network import MLPClassifier
from sklearn.preprocessing import scale, StandardScaler
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
yapay sinir ağları genelde homojen veri setleri üzerinde daha iyi çalıştığından dolayı standartlaşma işlemi uygulanması gerekiyor
scaler= StandardScaler()
scaler.fit(x_train)
x_train= scaler.transform(x_train)
scaler.fit(x_test)
x_test= scaler.transform(x_test)
mlpc_model= MLPClassifier().fit(x_train,y_train)
mlpc_model
MLPClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
MLPClassifier()
mlpc_model.coefs_
[array([[ 6.45444925e-02, -1.45724306e-01, -1.78402760e-03,
-8.29426816e-02, -3.62620725e-02, -1.59528463e-01,
-1.44318684e-01, -1.49082050e-01, -1.95805489e-01,
-3.06053930e-02, -1.53487557e-01, 7.90392358e-02,
1.25638476e-01, 3.84571164e-02, 1.70108154e-01,
1.41215377e-02, -2.47106870e-02, -3.53728864e-02,
1.00505266e-01, -6.55616563e-02, 2.26623514e-01,
1.87855944e-01, 1.93569669e-04, 7.35469381e-02,
1.57274965e-01, 1.01644594e-01, -1.63297986e-03,
-8.19642063e-03, -2.53207312e-01, -4.61899481e-02,
2.14739196e-01, 1.83492423e-01, 8.00502703e-04,
-1.39858361e-01, -6.16501050e-02, 1.34984348e-02,
-2.23150209e-01, -1.19055179e-01, 9.28647591e-03,
1.43016576e-01, 1.52975700e-01, 3.51834441e-01,
5.73214182e-02, 2.49236636e-01, -1.49158944e-02,
1.52101575e-01, -2.50990382e-01, 4.97402923e-02,
1.28931097e-01, 1.04352922e-02, -8.80367767e-02,
-3.01753408e-02, -1.83668219e-01, 4.33561608e-12,
1.27202928e-02, 1.45349208e-01, 7.79164903e-02,
2.08299581e-01, -1.58498256e-01, 2.27995593e-02,
-6.87691299e-02, -2.38446603e-01, 1.69554782e-01,
1.50499144e-01, -2.22338183e-01, 1.23250273e-03,
1.59213729e-01, -1.18626280e-01, 1.33341092e-01,
-3.11806465e-02, 1.83037349e-01, 1.02779819e-02,
-3.86333242e-02, 1.24532902e-05, -2.35207272e-04,
-5.51430161e-02, -1.70419443e-02, 2.14958268e-02,
2.70176692e-01, -1.97683530e-02, 1.41223781e-01,
-8.36485874e-02, -2.99498495e-01, -6.12811184e-02,
2.97456337e-01, 1.24946604e-02, 1.69774591e-02,
1.99947558e-01, 6.74548596e-02, -1.94405399e-02,
-8.49355756e-02, -9.48789814e-02, -1.88779987e-01,
5.55960720e-02, 5.13421427e-10, -4.89607850e-05,
-2.16935780e-02, -3.81318255e-03, -8.46394196e-02,
1.39662624e-01],
[-6.17429506e-02, 1.89932324e-01, -9.92554384e-03,
3.00727310e-03, 7.85993375e-02, 1.73876586e-01,
1.27155128e-01, 1.13811070e-01, 4.30577966e-02,
1.30710371e-01, 1.23900717e-01, 2.04818148e-01,
-1.53514809e-01, 8.36626090e-02, 1.28983069e-01,
-6.64380846e-02, 1.13257066e-01, -4.16908534e-02,
2.18001567e-01, -1.97507694e-01, 1.63362075e-01,
8.32404644e-02, -1.19162227e-03, -2.79011850e-02,
1.49146606e-01, -1.60261161e-01, -1.97690932e-03,
1.08454914e-01, 1.22357305e-01, 4.02657446e-04,
6.44963045e-02, -1.02895558e-01, -4.38818799e-02,
1.50243271e-01, 1.61847820e-01, -8.43676086e-02,
-9.96789612e-02, -8.68465742e-02, -2.55412110e-02,
1.45803201e-01, 1.04112291e-01, -2.61393714e-01,
1.15361899e-01, -1.08366608e-01, 9.45407045e-02,
1.36953441e-01, -4.26357275e-02, -1.70022706e-01,
1.02092604e-01, 1.17586815e-01, -2.30035034e-01,
-1.88930419e-01, 2.60815279e-02, -6.94212143e-11,
1.21222854e-01, -1.31665234e-01, 6.08379031e-03,
1.05211796e-01, 1.58213198e-01, -1.47996291e-01,
-7.26469915e-03, 9.02698405e-02, 3.27559640e-02,
-1.34424919e-01, 1.09899344e-01, -2.39671094e-03,
1.90033301e-02, -3.30784244e-02, 2.30338438e-01,
-2.80921429e-02, -7.24766002e-02, 1.53925216e-01,
1.85560104e-01, -1.40241439e-03, -2.73889705e-03,
2.88868322e-03, -2.07841614e-02, 4.15724177e-02,
4.41319293e-02, 1.82312249e-01, 5.35194926e-03,
1.23306694e-01, -5.96764385e-02, 1.57219179e-01,
-6.05453269e-02, 9.16376411e-02, -1.11127826e-01,
-2.14891899e-01, 1.35341786e-01, 5.72363580e-02,
1.03645078e-01, 8.17621140e-02, 5.09157258e-02,
4.48876460e-02, -1.19523099e-02, -2.07936512e-04,
6.34009706e-02, -8.54078858e-02, -5.10941414e-02,
1.10010215e-01],
[ 2.16250578e-02, 3.85475486e-02, -8.79905014e-03,
-2.53978534e-02, -5.31461567e-02, 1.81096568e-01,
1.09268437e-01, -1.25524046e-01, 1.55088796e-01,
1.47499977e-02, -9.78400983e-02, 1.32408180e-01,
-3.12269275e-02, -2.58302512e-03, -6.29223030e-03,
1.98099332e-01, -1.33905347e-01, -3.70129012e-02,
-8.48295065e-02, 1.81249773e-01, 2.27901993e-01,
-1.91867559e-01, -1.08718435e-02, 3.22704678e-02,
7.35042466e-02, 9.20512452e-02, -9.70290080e-04,
1.05985060e-01, 5.40076104e-02, 1.35986858e-01,
4.62924428e-02, 4.62988276e-02, 5.12968058e-02,
-1.58904051e-01, -8.22076502e-02, -1.68601992e-01,
-5.72256296e-02, -1.82413626e-01, 2.32591055e-01,
1.14054752e-01, 2.18622560e-01, -1.29986990e-01,
1.03217300e-01, 4.69308914e-02, 2.00663360e-01,
1.29062856e-01, 1.88247946e-01, -2.56112156e-02,
-1.92117808e-02, 2.19725869e-01, 1.62743839e-01,
-3.10413117e-02, 1.23333714e-01, -3.36596565e-03,
-1.60354164e-01, 1.57046500e-01, -3.94233278e-02,
1.05390077e-01, -5.15769323e-02, 9.99720582e-02,
-8.49626279e-02, -5.40765147e-02, 2.35437914e-01,
2.30835336e-01, -1.43484262e-01, -9.39181458e-03,
7.30024143e-02, 1.38173126e-01, -1.41544885e-01,
-1.81211653e-02, 3.77297197e-02, 1.34435442e-01,
-2.13866093e-01, -3.97548365e-03, -1.52875935e-02,
2.06732229e-01, -1.75162050e-02, 2.75646757e-02,
-2.61778929e-02, 7.17691012e-02, 4.95131970e-02,
-1.15188872e-01, -9.30634090e-02, -2.63505989e-01,
-4.25628972e-02, 1.80000754e-01, -2.48665206e-01,
-1.11366588e-02, 2.29619705e-01, 1.05304060e-02,
1.55541653e-01, -2.13023892e-01, -1.82616829e-01,
8.53990814e-02, -1.40141640e-04, 1.91837504e-05,
-1.38056107e-01, -9.72921586e-02, -2.12988790e-01,
-1.84146937e-01],
[ 1.82410391e-01, -1.57341988e-01, -1.52453967e-02,
1.85398170e-01, -9.02732215e-02, -1.04937795e-01,
2.31750731e-01, -1.41412500e-01, 1.72655504e-01,
1.36059229e-01, 1.19023774e-01, -3.62965779e-02,
1.59538881e-01, 2.17471130e-01, -1.46106420e-01,
-8.73155750e-02, 9.65726115e-02, -1.89004637e-02,
2.27983973e-01, -1.20496641e-01, 2.06237775e-01,
1.02285890e-01, -1.28699310e-04, -1.31761096e-01,
-1.32998988e-01, 1.76367386e-02, 3.19893607e-09,
1.90992744e-01, 9.23757742e-02, -2.31303476e-01,
7.31910669e-02, -2.31047167e-01, -6.39094393e-02,
-1.50648951e-01, 4.64727316e-02, -1.12335002e-01,
-1.43127712e-01, -1.96547763e-02, -9.02834485e-02,
3.37964241e-02, -1.83374326e-01, -2.97640351e-03,
-1.54890066e-01, 2.73686932e-01, 7.93513525e-02,
1.33671655e-01, 2.28587267e-01, 1.21366669e-01,
-2.58258078e-02, 1.92242587e-01, -8.24420283e-02,
2.35770083e-02, 1.38706850e-01, 1.08319399e-06,
1.69465380e-01, 1.23490351e-02, 1.54306023e-01,
1.86409321e-01, -1.57301441e-01, 2.17101384e-01,
-1.75613497e-01, 9.66944905e-02, -1.76739533e-01,
9.08781234e-02, -1.30773175e-01, -8.24090349e-04,
2.23363166e-01, -1.94929369e-01, -2.40538198e-01,
-1.34702933e-02, 3.87011395e-03, 2.69169982e-02,
-2.07556188e-01, 4.23299640e-06, 6.42001824e-05,
4.89505807e-02, -8.34726151e-03, 1.61338477e-02,
1.31669852e-01, 2.45683871e-02, -2.13537566e-01,
-4.98340304e-02, -2.28718899e-02, -4.08941379e-02,
-8.22232895e-03, -7.49184636e-02, 9.01000141e-03,
2.62588938e-02, -1.34374966e-01, 1.66672524e-01,
1.56894886e-01, 1.39015270e-01, -2.90355950e-02,
7.75201470e-03, -8.19200474e-03, 3.99920570e-05,
-1.24367053e-01, -4.52664597e-02, -8.29741936e-02,
-2.06740553e-01],
[-1.25976859e-01, -3.14514979e-02, -1.75449139e-03,
-5.57224183e-03, 2.39350174e-01, -1.06871921e-01,
-2.09548581e-01, -1.31939652e-01, 1.80856378e-01,
-9.89520194e-02, 8.28924521e-02, 1.97004632e-01,
-1.95619669e-01, -2.45212570e-01, -9.66723975e-02,
-1.45359946e-01, -2.27272565e-01, 2.78246238e-10,
-3.83298879e-02, 5.63257776e-02, 1.77252523e-01,
-3.34766009e-01, -2.55252850e-03, 1.74162057e-01,
3.06041599e-02, 1.72546510e-01, 1.54385693e-07,
-2.52142478e-01, 1.18476655e-01, -1.82406166e-01,
-9.08812660e-02, 1.33267274e-02, 9.41680871e-02,
5.33205074e-02, 1.56577619e-01, -2.57938989e-03,
1.75930285e-01, 1.21396434e-01, 3.99627008e-02,
8.28631392e-02, -9.49519188e-02, -1.60880890e-01,
-7.17937284e-02, -2.38681906e-01, -1.05976938e-01,
-2.47267880e-01, 1.93407779e-01, 1.94482391e-01,
4.06305109e-02, -5.79530342e-02, 9.97977664e-02,
1.22402365e-01, -1.41395073e-01, -4.67030339e-03,
-1.14302885e-01, -1.86860051e-01, -1.68928169e-01,
8.21642208e-02, 2.23881022e-01, 1.01704870e-02,
1.75984877e-01, -3.91999757e-02, -2.54469873e-02,
2.15365767e-01, -2.17424443e-01, -3.79154306e-05,
1.85325418e-01, -9.24462617e-02, 3.11143173e-02,
-7.89052045e-03, -1.43292960e-05, -1.05032714e-01,
4.80345567e-02, -1.28326563e-03, -6.95243224e-03,
-1.54740927e-01, 5.14063381e-10, 1.05338262e-01,
1.12836180e-01, -1.64037381e-01, -6.48217177e-02,
-1.00283118e-01, 2.32821509e-01, -3.60428979e-02,
-5.54232828e-04, -1.54984539e-01, 2.17591882e-01,
1.35645588e-01, -6.53821049e-02, 1.27073928e-01,
1.83049364e-01, 1.57740863e-01, -1.93747071e-01,
3.68506374e-03, -1.79799669e-05, -3.16284934e-06,
1.16073461e-01, 1.66318818e-01, 1.89982209e-01,
1.00001660e-01],
[ 1.74587877e-02, 1.78527962e-01, 1.49599683e-03,
-1.74046282e-01, -1.33874487e-01, -1.60634321e-01,
-1.28921435e-01, 1.35547218e-01, 1.85346464e-01,
-1.62144799e-01, -2.03648916e-01, 6.35606703e-02,
1.96461178e-01, -2.16655487e-01, 2.30884161e-01,
8.44688652e-02, 2.35630668e-01, 2.77914963e-02,
3.05852062e-02, 1.79400312e-01, -1.54066473e-01,
2.10278345e-01, -8.02921236e-03, -7.01168749e-02,
1.02591610e-01, 2.08532059e-01, -7.73018455e-04,
1.67387949e-01, 4.43725252e-02, 1.62756951e-01,
7.93096113e-02, -1.08090669e-01, 8.52141203e-02,
2.25017239e-01, -1.08406849e-01, 7.17143942e-02,
3.73078261e-02, 9.92099255e-02, 2.08838180e-01,
3.77133860e-02, -1.42946507e-01, 2.24231375e-01,
1.18292067e-01, 1.25443716e-01, 1.54470393e-01,
-2.12375875e-01, -3.64698518e-02, -2.19679249e-01,
3.61611932e-02, -1.42750166e-01, 5.60233157e-02,
1.21175689e-01, 7.22978716e-02, -5.65260198e-04,
-3.36038092e-03, 2.08138022e-01, -1.23052629e-01,
-1.07585462e-01, -3.77746738e-02, -2.06915696e-01,
1.59512053e-01, -1.18510759e-01, -9.69541921e-02,
1.67477196e-02, 1.11330368e-01, -1.20369740e-02,
-7.95784047e-04, -7.14756996e-03, 1.33358116e-01,
-2.29615954e-02, -1.83186892e-01, -7.10701260e-02,
2.91711528e-02, -1.32263368e-04, 5.83452094e-05,
-2.13006111e-01, -1.75136878e-02, -1.18844971e-01,
6.45613342e-02, 9.53366310e-02, 1.30249744e-01,
-1.32345394e-01, 2.00611981e-03, -1.30884295e-01,
8.04802550e-02, 1.11115101e-01, 1.42200541e-01,
1.15293165e-01, -4.00743052e-03, -1.42283419e-01,
-1.84300444e-01, 6.91776300e-02, 1.06590000e-01,
-5.85449793e-02, -9.99517778e-04, -4.80292072e-03,
-2.11624030e-01, 1.46322987e-01, -9.73446054e-02,
-4.46520018e-02],
[ 7.22393730e-02, -1.88553498e-01, -7.94033989e-03,
-1.05917911e-01, -8.88747307e-03, 2.13844754e-01,
3.57707795e-02, 2.68590464e-01, 1.39424668e-02,
-9.47142050e-03, 5.73284016e-03, -6.02683667e-02,
5.59174437e-02, 1.95761125e-01, -4.70383033e-02,
-1.58122471e-02, 1.88011640e-01, 1.06568288e-02,
-2.04762309e-01, 1.08804394e-01, 1.22023815e-02,
1.60200005e-02, 4.70004286e-10, 8.17144354e-02,
-4.08214856e-02, -1.29112868e-01, 3.37455282e-08,
9.60875995e-02, 1.40195747e-01, 4.62906471e-02,
-1.64748273e-01, 2.11700183e-01, -2.29922985e-01,
1.46063583e-01, -1.37174477e-01, -2.03700360e-01,
-7.39758494e-02, 1.70556762e-01, 1.99564556e-01,
-2.52253878e-02, -1.61206276e-01, -8.95778074e-02,
-2.13604547e-02, 4.70364117e-01, 6.73413436e-02,
-1.29587377e-01, 1.34013717e-01, -4.84177194e-02,
-2.06247148e-01, 2.03789106e-01, -2.24239399e-01,
-8.28956793e-02, -9.25723769e-02, -1.40985282e-04,
-5.05824744e-02, -1.73807961e-01, 4.29571466e-02,
6.07576678e-02, 1.37893840e-02, 1.03588716e-01,
-2.10123769e-01, -1.47280147e-01, 5.20382721e-02,
-1.23459719e-01, 1.53881850e-01, -2.67547013e-04,
6.83981626e-02, 8.16296529e-02, 1.00922403e-01,
6.59983796e-03, -1.27866050e-03, -9.14148254e-03,
2.64823496e-02, -4.38874527e-11, -9.04063914e-03,
-2.12350612e-01, -1.68270576e-02, -2.06101989e-01,
1.10342659e-01, -8.10634124e-02, 3.21737446e-02,
2.40380162e-01, 9.56745202e-02, 2.31795154e-01,
1.24466449e-01, 1.55592296e-01, 1.47093384e-01,
4.18839510e-02, 1.52291462e-01, -7.49036879e-02,
-1.78949129e-01, -7.29837866e-02, 3.17530968e-02,
1.63135576e-01, 5.45616230e-03, -5.14314002e-10,
6.22721378e-02, 1.34177188e-01, -6.90255532e-02,
1.39537375e-01],
[ 3.08104958e-02, -1.44037531e-01, -3.06927278e-12,
5.34702447e-02, -2.89297084e-02, -2.98064743e-02,
1.58779479e-01, 3.91920206e-02, -3.45644611e-02,
1.86828455e-01, -1.22037055e-01, -1.87045031e-02,
6.01835353e-02, 2.29396566e-02, -1.32325054e-01,
-4.78617960e-02, 2.06928311e-01, 6.17921287e-03,
1.46844796e-01, 4.27299436e-03, 4.53881010e-02,
5.25282517e-02, -7.44972548e-03, -5.94706199e-02,
8.98869251e-02, -1.81493977e-01, -3.11495119e-04,
7.94565885e-02, 4.46743043e-02, -1.68734459e-01,
-2.05193004e-01, 7.21662820e-02, 9.06218762e-02,
-3.19823109e-02, 6.58798037e-02, 1.17684682e-01,
-5.52421585e-02, 1.67094380e-01, -1.98949693e-01,
-9.60967729e-03, -1.17091827e-01, 2.07215674e-01,
-1.61748207e-01, -3.94288325e-02, 1.87538462e-01,
1.28384993e-02, -1.35759379e-01, 2.14628214e-01,
1.69129211e-01, -2.07669695e-01, 1.11300672e-01,
-2.69744120e-01, -1.26641907e-03, -8.75268807e-03,
1.43950569e-01, 9.66290682e-02, 4.38652406e-02,
2.11554415e-01, 1.01274862e-01, 8.21879693e-02,
-1.23968104e-01, 1.23289404e-01, -5.26739475e-02,
1.70099312e-01, 1.45440496e-01, -6.56505043e-03,
-3.67608177e-02, 1.94719127e-01, -1.97071658e-01,
-1.05803814e-02, 6.03680968e-02, -1.14625838e-01,
1.91643765e-01, 5.53451850e-04, 1.24270509e-03,
-2.08386456e-01, -1.85177584e-02, -1.89299820e-01,
-1.51554768e-01, -9.80680866e-03, -1.31688828e-02,
-2.30232536e-01, -6.02653102e-02, 3.71492361e-02,
2.24249576e-02, -1.56879010e-01, -1.38809227e-01,
2.13641109e-01, -9.77098473e-03, -1.47123180e-01,
1.65972481e-01, 9.90208099e-02, -1.87630307e-01,
7.93925546e-02, -1.19630478e-02, -1.07804154e-04,
-1.40597717e-01, -2.17739956e-01, -1.45209940e-01,
-1.54306522e-01]]),
array([[ 2.68942122e-01],
[-4.77370667e-02],
[-7.04462921e-05],
[-3.48637116e-01],
[-1.54190190e-01],
[ 1.56047661e-01],
[-1.15128934e-01],
[-2.88210932e-02],
[ 7.87701257e-02],
[ 1.47691390e-01],
[ 2.01749746e-01],
[-7.88019764e-02],
[-3.88967464e-02],
[ 1.42715936e-01],
[-4.63054725e-02],
[-9.99356262e-02],
[-7.66369561e-02],
[ 3.10586185e-02],
[-2.35599221e-01],
[-1.06107323e-01],
[ 1.87552133e-01],
[ 6.24427995e-02],
[-1.21028705e-04],
[-2.17999601e-04],
[ 1.44869813e-01],
[-1.26987162e-02],
[-1.02012937e-02],
[ 7.98791916e-02],
[-7.05093504e-02],
[ 1.79744820e-01],
[ 2.87107107e-02],
[ 1.43051771e-01],
[ 5.58333797e-02],
[-1.10246211e-01],
[ 2.24089520e-01],
[ 1.38007383e-01],
[-2.50835681e-01],
[ 5.61972007e-02],
[-1.94017230e-01],
[ 2.12647951e-01],
[ 6.05501156e-02],
[ 1.91510545e-01],
[-1.21138397e-01],
[ 1.19052801e-01],
[ 8.24324866e-02],
[-1.28314426e-01],
[-1.46003329e-01],
[ 7.75797680e-02],
[-2.19151116e-01],
[-7.21864873e-02],
[ 1.94122901e-01],
[-8.77937828e-02],
[ 1.94179217e-01],
[-2.39947580e-11],
[ 8.33812027e-02],
[ 3.59993859e-02],
[-9.39927185e-02],
[ 4.67064574e-02],
[ 1.57162002e-01],
[-1.32042312e-01],
[ 1.16541501e-01],
[-1.49032028e-01],
[-1.53736868e-01],
[-1.68269540e-01],
[ 1.70568474e-01],
[ 1.35753686e-02],
[-2.91458401e-02],
[-1.26415369e-01],
[-9.61228077e-03],
[ 1.11587511e-02],
[-2.45383693e-02],
[-3.87288232e-02],
[-1.78066339e-01],
[-7.50446016e-04],
[-1.15989931e-02],
[-1.21652299e-01],
[-7.68644733e-03],
[ 2.12088482e-01],
[ 8.53791564e-02],
[-4.52203282e-02],
[ 2.02148051e-01],
[ 2.03592289e-01],
[-9.52405747e-02],
[-1.99828933e-01],
[ 3.13333247e-01],
[-1.44388008e-01],
[ 3.84985337e-02],
[ 1.16026415e-01],
[ 1.84456113e-01],
[-1.43387592e-01],
[-2.45659576e-01],
[ 2.01989796e-01],
[ 1.59320723e-01],
[-7.88899370e-02],
[ 1.03192357e-07],
[-1.09601807e-03],
[-7.45593973e-02],
[ 8.62688225e-02],
[-4.49390354e-02],
[-3.09125248e-02]])]
?mlpc_model
y_pred= mlpc_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7316017316017316
mlpc_params= {"hidden_layer_sizes":[(10,10),(100,100,100),(100,100),(3,5)],
"alpha":[1,5,0.1,0.01,0.03,0.05,0.0001]}
mlpc= MLPClassifier(solver="lbfgs",activation= "logistic") # sınıflandırma problemlerinde activationu logistic yapmamız gerekiyor
mlpc_cv_model= GridSearchCV(mlpc,mlpc_params,cv=10,n_jobs=-1,verbose=2).fit(x_train,y_train)
Fitting 10 folds for each of 28 candidates, totalling 280 fits
C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\neural_network\_multilayer_perceptron.py:546: ConvergenceWarning: lbfgs failed to converge (status=1):
STOP: TOTAL NO. of ITERATIONS REACHED LIMIT.
Increase the number of iterations (max_iter) or scale the data as shown in:
https://scikit-learn.org/stable/modules/preprocessing.html
self.n_iter_ = _check_optimize_result("lbfgs", opt_res, self.max_iter)
mlpc_cv_model
GridSearchCV(cv=10,
estimator=MLPClassifier(activation='logistic', solver='lbfgs'),
n_jobs=-1,
param_grid={'alpha': [1, 5, 0.1, 0.01, 0.03, 0.05, 0.0001],
'hidden_layer_sizes': [(10, 10), (100, 100, 100),
(100, 100), (3, 5)]},
verbose=2)In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. GridSearchCV(cv=10,
estimator=MLPClassifier(activation='logistic', solver='lbfgs'),
n_jobs=-1,
param_grid={'alpha': [1, 5, 0.1, 0.01, 0.03, 0.05, 0.0001],
'hidden_layer_sizes': [(10, 10), (100, 100, 100),
(100, 100), (3, 5)]},
verbose=2)MLPClassifier(activation='logistic', solver='lbfgs')
MLPClassifier(activation='logistic', solver='lbfgs')
mlpc_cv_model.best_params_
{'alpha': 5, 'hidden_layer_sizes': (100, 100)}
mlpc_tuned= MLPClassifier(solver="lbfgs",alpha=5,hidden_layer_sizes=(100,100),activation= "logistic").fit(x_train,y_train)
y_pred= mlpc_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7359307359307359
libraries used in this field
from sklearn.tree import DecisionTreeClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42);
cart_model= DecisionTreeClassifier().fit(x_train,y_train)
cart_model
DecisionTreeClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
DecisionTreeClassifier()
y_pred= cart_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7056277056277056
cart= DecisionTreeClassifier()
cart_params= {"max_depth": [1,3,5,8,10],
"min_samples_split":[2,3,5,10,20,50]}
cart_cv_model= GridSearchCV(cart,cart_params,n_jobs=-1,verbose=2).fit(x_train,y_train)
Fitting 5 folds for each of 30 candidates, totalling 150 fits
cart_cv_model.best_params_
{'max_depth': 5, 'min_samples_split': 50}
cart_tuned= DecisionTreeClassifier(max_depth=5,min_samples_split=50).fit(x_train,y_train)
y_pred= cart_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7575757575757576
libraries used in this field
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
rf_model= RandomForestClassifier().fit(x_train,y_train)
rf_model
RandomForestClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
RandomForestClassifier()
y_pred= rf_model.predict(x_test)
accuracy_score(y_test, y_pred)
0.7532467532467533
rf= RandomForestClassifier()
rf_params= {"n_estimators":[100,200,500,1000],
"max_features":[3,5,7,8],
"min_samples_split": [2,5,10,20]}
rf_cv_model= GridSearchCV(rf,rf_params,cv=10,n_jobs=-1,verbose=2).fit(x_train,y_train)
Fitting 10 folds for each of 64 candidates, totalling 640 fits
rf_cv_model.best_params_
{'max_features': 5, 'min_samples_split': 5, 'n_estimators': 200}
rf_tuned= RandomForestClassifier(n_estimators=200,max_features=5,min_samples_split=5).fit(x_train,y_train)
y_pred= rf_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7575757575757576
# değişken önem düzeyi
rf_tuned.feature_importances_
array([0.05501306, 0.35020139, 0.07096524, 0.05014943, 0.0529208 ,
0.17518745, 0.10316439, 0.14239823])
feature= pd.Series(rf_tuned.feature_importances_,
index=x_train.columns).sort_values(ascending=False)
sns.barplot(x=feature, y=feature.index)
plt.xlabel('Değişken Önem Skorlarrı')
plt.ylabel('Değişkenler')
plt.title('Değişken Önem Düzeyleri')
plt.show()
libraries used in this field
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
gbm_model= GradientBoostingClassifier().fit(x_train,y_train)
gbm_model
GradientBoostingClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
GradientBoostingClassifier()
?gbm_model
y_pred= gbm_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7532467532467533
gbm= GradientBoostingClassifier()
gbm_params= {"learning_rate":[0.1,0.01,0.001,0.05],
"n_estimators":[100,300,500,1000],
"max_depth":[2,3,5,8]}
gbm_cv_model= GridSearchCV(gbm,gbm_params,cv=10,n_jobs=-1,verbose=2).fit(x_train,y_train)
gbm_cv_model.best_params_
gbm_tuned= GradientBoostingClassifier(learning_rate=0.01,
n_estimators=5,
max_depth=500).fit(x_train,y_train)
y_pred= gbm_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.6536796536796536
# değişken önem düzeyi
feature= pd.Series(gbm_tuned.feature_importances_,
index=x_train.columns).sort_values(ascending=False)
sns.barplot(x=feature, y=feature.index)
plt.xlabel('Değişken Önem Skorlarrı')
plt.ylabel('Değişkenler')
plt.title('Değişken Önem Düzeyleri')
plt.show()
libraries used in this field
!pip insatll xgboost
ERROR: unknown command "insatll" - maybe you meant "install"
from xgboost import XGBClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
xgb_model= XGBClassifier().fit(x_train,y_train)
?xgb_model
y_pred=xgb_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7272727272727273
xgb= XGBClassifier()
xgb_params= {"n_estimators":[100,500,1000],
"subsample":[0.6,0.8,1],
"max_depth":[3,5,7],
"learning_rate":[0.1,0.001,0.01]}
xgb_cv_model= GridSearchCV(xgb,xgb_params,cv=10,n_jobs=-1,verbose=2).fit(x_train,y_train)
Fitting 10 folds for each of 81 candidates, totalling 810 fits
xgb_cv_model.best_params_
{'learning_rate': 0.01, 'max_depth': 3, 'n_estimators': 500, 'subsample': 0.8}
xgb_tuned= XGBClassifier(learning_rate=0.01 ,
max_depth=3 ,
n_estimators=500 ,
subsample= 0.8).fit(x_train,y_train)
y_pred= xgb_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7619047619047619
feature= pd.Series(xgb_tuned.feature_importances_,
index=x_train.columns).sort_values(ascending=False)
sns.barplot(x=feature, y=feature.index)
plt.xlabel('Değişken Önem Skorlarrı')
plt.ylabel('Değişkenler')
plt.title('Değişken Önem Düzeyleri')
plt.show()
libraries used in this field
!pip insatll lightgbm
ERROR: unknown command "insatll" - maybe you meant "install"
from lightgbm import LGBMClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
lgbm_model= LGBMClassifier().fit(x_train,y_train)
[LightGBM] [Info] Number of positive: 188, number of negative: 349 [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.000526 seconds. You can set `force_col_wise=true` to remove the overhead. [LightGBM] [Info] Total Bins 606 [LightGBM] [Info] Number of data points in the train set: 537, number of used features: 8 [LightGBM] [Info] [binary:BoostFromScore]: pavg=0.350093 -> initscore=-0.618630 [LightGBM] [Info] Start training from score -0.618630 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf
lgbm_model
LGBMClassifier()In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
LGBMClassifier()
?lgbm_model
y_predit= lgbm_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7619047619047619
lgbm= LGBMClassifier()
lgbm_params= {"learnin_rate":[0.001,0.01,0.01],
"n_estimators":[200,500,100],
"max_depth":[1,2,35,8]}
lgbm_cv_model= GridSearchCV(lgbm,lgbm_params,n_jobs=-1,verbose=2,cv=10).fit(x_train,y_train)
Fitting 10 folds for each of 36 candidates, totalling 360 fits [LightGBM] [Warning] Unknown parameter: learnin_rate [LightGBM] [Warning] Unknown parameter: learnin_rate [LightGBM] [Info] Number of positive: 188, number of negative: 349 [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.000309 seconds. You can set `force_col_wise=true` to remove the overhead. [LightGBM] [Info] Total Bins 606 [LightGBM] [Info] Number of data points in the train set: 537, number of used features: 8 [LightGBM] [Info] [binary:BoostFromScore]: pavg=0.350093 -> initscore=-0.618630 [LightGBM] [Info] Start training from score -0.618630 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf
lgbm_cv_model.best_params_
{'learnin_rate': 0.001, 'max_depth': 2, 'n_estimators': 100}
lgbm_tuned= LGBMClassifier(learning_rate=0.01,
max_depth=1,
n_estimators=500).fit(x_train,y_train)
[LightGBM] [Info] Number of positive: 188, number of negative: 349 [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.000301 seconds. You can set `force_col_wise=true` to remove the overhead. [LightGBM] [Info] Total Bins 606 [LightGBM] [Info] Number of data points in the train set: 537, number of used features: 8 [LightGBM] [Info] [binary:BoostFromScore]: pavg=0.350093 -> initscore=-0.618630 [LightGBM] [Info] Start training from score -0.618630
y_pred= lgbm_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7575757575757576
feature= pd.Series(lgbm_tuned.feature_importances_,
index=x_train.columns).sort_values(ascending=False)
sns.barplot(x=feature, y=feature.index)
plt.xlabel('Değişken Önem Skorlarrı')
plt.ylabel('Değişkenler')
plt.title('Değişken Önem Düzeyleri')
plt.show()
libraries used in this field
!pip insatll catboost
ERROR: unknown command "insatll" - maybe you meant "install"
from catboost import CatBoostClassifier
from sklearn.model_selection import train_test_split, GridSearchCV, cross_val_score
from sklearn.metrics import confusion_matrix, accuracy_score, mean_squared_error, r2_score, roc_auc_score, roc_curve, classification_report
data= pd.read_csv("C:\\data_set\\diabetes.csv")
y = data["Outcome"]
x= data.drop(["Outcome"],axis = 1)
x_train, x_test, y_train, y_test =train_test_split(x,y,test_size=0.30,random_state=42)
catb_model= CatBoostClassifier().fit(x_train,y_train,verbose=False)
y_pred= catb_model.predict(x_test)
accuracy_score(y_test,y_pred)
0.7402597402597403
catb= CatBoostClassifier(verbose=False)
catb_params= {"iterations":[200,500,1000],
"learning_rate": [0.01,0.03,0.1],
"depth": [4,5,8]}
# catb_cv_model= GridSearchCV(catb,catb_params,cv=5,n_jobs=-1,verbose=2).fit(x_train,y_train)
# catb_cv_model.best_params_
catb_tuned= CatBoostClassifier(depth=8,
iterations=200,
learning_rate=0.03).fit(x_train,y_train)
0: learn: 0.6730317 total: 9.05ms remaining: 1.8s 1: learn: 0.6582932 total: 17ms remaining: 1.68s 2: learn: 0.6413374 total: 29.7ms remaining: 1.95s 3: learn: 0.6267884 total: 38.1ms remaining: 1.87s 4: learn: 0.6150338 total: 46.6ms remaining: 1.82s 5: learn: 0.5988569 total: 64.4ms remaining: 2.08s 6: learn: 0.5860830 total: 85.6ms remaining: 2.36s 7: learn: 0.5734710 total: 104ms remaining: 2.5s 8: learn: 0.5616034 total: 126ms remaining: 2.67s 9: learn: 0.5507407 total: 136ms remaining: 2.59s 10: learn: 0.5388119 total: 145ms remaining: 2.49s 11: learn: 0.5264274 total: 153ms remaining: 2.4s 12: learn: 0.5191433 total: 164ms remaining: 2.35s 13: learn: 0.5104236 total: 173ms remaining: 2.3s 14: learn: 0.5016788 total: 181ms remaining: 2.23s 15: learn: 0.4954697 total: 189ms remaining: 2.18s 16: learn: 0.4896572 total: 208ms remaining: 2.23s 17: learn: 0.4808284 total: 229ms remaining: 2.31s 18: learn: 0.4723731 total: 248ms remaining: 2.37s 19: learn: 0.4656953 total: 269ms remaining: 2.42s 20: learn: 0.4613141 total: 286ms remaining: 2.44s 21: learn: 0.4536779 total: 294ms remaining: 2.38s 22: learn: 0.4488597 total: 301ms remaining: 2.32s 23: learn: 0.4438188 total: 309ms remaining: 2.26s 24: learn: 0.4371743 total: 323ms remaining: 2.26s 25: learn: 0.4327707 total: 341ms remaining: 2.28s 26: learn: 0.4274522 total: 362ms remaining: 2.32s 27: learn: 0.4214705 total: 381ms remaining: 2.34s 28: learn: 0.4160825 total: 401ms remaining: 2.36s 29: learn: 0.4116521 total: 412ms remaining: 2.33s 30: learn: 0.4073682 total: 423ms remaining: 2.3s 31: learn: 0.4012053 total: 434ms remaining: 2.28s 32: learn: 0.3970894 total: 445ms remaining: 2.25s 33: learn: 0.3908936 total: 454ms remaining: 2.21s 34: learn: 0.3868677 total: 461ms remaining: 2.17s 35: learn: 0.3836666 total: 469ms remaining: 2.14s 36: learn: 0.3799969 total: 478ms remaining: 2.1s 37: learn: 0.3768569 total: 493ms remaining: 2.1s 38: learn: 0.3726554 total: 511ms remaining: 2.11s 39: learn: 0.3691778 total: 531ms remaining: 2.12s 40: learn: 0.3655939 total: 549ms remaining: 2.13s 41: learn: 0.3616921 total: 570ms remaining: 2.14s 42: learn: 0.3580472 total: 583ms remaining: 2.13s 43: learn: 0.3556024 total: 594ms remaining: 2.1s 44: learn: 0.3520438 total: 603ms remaining: 2.08s 45: learn: 0.3493385 total: 612ms remaining: 2.05s 46: learn: 0.3456439 total: 621ms remaining: 2.02s 47: learn: 0.3432385 total: 629ms remaining: 1.99s 48: learn: 0.3400849 total: 637ms remaining: 1.96s 49: learn: 0.3353309 total: 645ms remaining: 1.94s 50: learn: 0.3333735 total: 654ms remaining: 1.91s 51: learn: 0.3299440 total: 662ms remaining: 1.88s 52: learn: 0.3279711 total: 680ms remaining: 1.89s 53: learn: 0.3252567 total: 699ms remaining: 1.89s 54: learn: 0.3233230 total: 718ms remaining: 1.89s 55: learn: 0.3206790 total: 736ms remaining: 1.89s 56: learn: 0.3180869 total: 754ms remaining: 1.89s 57: learn: 0.3160875 total: 765ms remaining: 1.87s 58: learn: 0.3140489 total: 776ms remaining: 1.85s 59: learn: 0.3127124 total: 784ms remaining: 1.83s 60: learn: 0.3109795 total: 792ms remaining: 1.8s 61: learn: 0.3081993 total: 801ms remaining: 1.78s 62: learn: 0.3058535 total: 808ms remaining: 1.76s 63: learn: 0.3034111 total: 816ms remaining: 1.73s 64: learn: 0.3007186 total: 824ms remaining: 1.71s 65: learn: 0.2988902 total: 832ms remaining: 1.69s 66: learn: 0.2974293 total: 840ms remaining: 1.67s 67: learn: 0.2951830 total: 863ms remaining: 1.67s 68: learn: 0.2917267 total: 882ms remaining: 1.67s 69: learn: 0.2903607 total: 888ms remaining: 1.65s 70: learn: 0.2882471 total: 910ms remaining: 1.65s 71: learn: 0.2863627 total: 927ms remaining: 1.65s 72: learn: 0.2847011 total: 938ms remaining: 1.63s 73: learn: 0.2830881 total: 948ms remaining: 1.61s 74: learn: 0.2805163 total: 959ms remaining: 1.6s 75: learn: 0.2788447 total: 967ms remaining: 1.58s 76: learn: 0.2761505 total: 976ms remaining: 1.56s 77: learn: 0.2749231 total: 984ms remaining: 1.54s 78: learn: 0.2733597 total: 992ms remaining: 1.52s 79: learn: 0.2722927 total: 1000ms remaining: 1.5s 80: learn: 0.2709836 total: 1.01s remaining: 1.48s 81: learn: 0.2698701 total: 1.02s remaining: 1.47s 82: learn: 0.2683076 total: 1.04s remaining: 1.47s 83: learn: 0.2669109 total: 1.06s remaining: 1.47s 84: learn: 0.2647336 total: 1.08s remaining: 1.46s 85: learn: 0.2634293 total: 1.1s remaining: 1.46s 86: learn: 0.2621911 total: 1.11s remaining: 1.44s 87: learn: 0.2605138 total: 1.12s remaining: 1.42s 88: learn: 0.2594740 total: 1.13s remaining: 1.4s 89: learn: 0.2585352 total: 1.14s remaining: 1.39s 90: learn: 0.2569049 total: 1.16s remaining: 1.38s 91: learn: 0.2560202 total: 1.18s remaining: 1.38s 92: learn: 0.2543659 total: 1.2s remaining: 1.38s 93: learn: 0.2517455 total: 1.22s remaining: 1.37s 94: learn: 0.2506967 total: 1.23s remaining: 1.36s 95: learn: 0.2494585 total: 1.24s remaining: 1.34s 96: learn: 0.2473779 total: 1.25s remaining: 1.33s 97: learn: 0.2461214 total: 1.26s remaining: 1.31s 98: learn: 0.2449923 total: 1.27s remaining: 1.29s 99: learn: 0.2443683 total: 1.27s remaining: 1.27s 100: learn: 0.2436926 total: 1.28s remaining: 1.26s 101: learn: 0.2431051 total: 1.29s remaining: 1.24s 102: learn: 0.2418184 total: 1.3s remaining: 1.22s 103: learn: 0.2409622 total: 1.32s remaining: 1.22s 104: learn: 0.2403718 total: 1.34s remaining: 1.21s 105: learn: 0.2383218 total: 1.36s remaining: 1.21s 106: learn: 0.2374951 total: 1.38s remaining: 1.2s 107: learn: 0.2355808 total: 1.4s remaining: 1.19s 108: learn: 0.2347997 total: 1.41s remaining: 1.18s 109: learn: 0.2339094 total: 1.42s remaining: 1.16s 110: learn: 0.2323558 total: 1.43s remaining: 1.14s 111: learn: 0.2311310 total: 1.43s remaining: 1.13s 112: learn: 0.2300307 total: 1.44s remaining: 1.11s 113: learn: 0.2292299 total: 1.45s remaining: 1.09s 114: learn: 0.2286090 total: 1.46s remaining: 1.08s 115: learn: 0.2266665 total: 1.47s remaining: 1.06s 116: learn: 0.2256470 total: 1.48s remaining: 1.05s 117: learn: 0.2250197 total: 1.49s remaining: 1.03s 118: learn: 0.2242045 total: 1.51s remaining: 1.02s 119: learn: 0.2233188 total: 1.52s remaining: 1.02s 120: learn: 0.2222564 total: 1.54s remaining: 1.01s 121: learn: 0.2217455 total: 1.56s remaining: 998ms 122: learn: 0.2206488 total: 1.57s remaining: 985ms 123: learn: 0.2184009 total: 1.58s remaining: 970ms 124: learn: 0.2174793 total: 1.59s remaining: 955ms 125: learn: 0.2155648 total: 1.6s remaining: 940ms 126: learn: 0.2149142 total: 1.61s remaining: 924ms 127: learn: 0.2132945 total: 1.62s remaining: 909ms 128: learn: 0.2120564 total: 1.62s remaining: 894ms 129: learn: 0.2102406 total: 1.64s remaining: 884ms 130: learn: 0.2091022 total: 1.66s remaining: 875ms 131: learn: 0.2083464 total: 1.68s remaining: 867ms 132: learn: 0.2081746 total: 1.69s remaining: 850ms 133: learn: 0.2075415 total: 1.71s remaining: 840ms 134: learn: 0.2065361 total: 1.72s remaining: 827ms 135: learn: 0.2056145 total: 1.73s remaining: 812ms 136: learn: 0.2050039 total: 1.73s remaining: 798ms 137: learn: 0.2043998 total: 1.74s remaining: 783ms 138: learn: 0.2039071 total: 1.75s remaining: 770ms 139: learn: 0.2022818 total: 1.77s remaining: 760ms 140: learn: 0.2013156 total: 1.79s remaining: 750ms 141: learn: 0.2001301 total: 1.81s remaining: 740ms 142: learn: 0.1991370 total: 1.83s remaining: 730ms 143: learn: 0.1982389 total: 1.84s remaining: 715ms 144: learn: 0.1971621 total: 1.85s remaining: 701ms 145: learn: 0.1953999 total: 1.86s remaining: 687ms 146: learn: 0.1943254 total: 1.86s remaining: 673ms 147: learn: 0.1933229 total: 1.87s remaining: 658ms 148: learn: 0.1923080 total: 1.88s remaining: 644ms 149: learn: 0.1908673 total: 1.89s remaining: 631ms 150: learn: 0.1900431 total: 1.91s remaining: 620ms 151: learn: 0.1895706 total: 1.93s remaining: 609ms 152: learn: 0.1885998 total: 1.94s remaining: 597ms 153: learn: 0.1879384 total: 1.96s remaining: 587ms 154: learn: 0.1872544 total: 1.98s remaining: 575ms 155: learn: 0.1858131 total: 1.99s remaining: 561ms 156: learn: 0.1847201 total: 2s remaining: 548ms 157: learn: 0.1834393 total: 2.01s remaining: 534ms 158: learn: 0.1827037 total: 2.02s remaining: 520ms 159: learn: 0.1819670 total: 2.02s remaining: 506ms 160: learn: 0.1814510 total: 2.03s remaining: 492ms 161: learn: 0.1806783 total: 2.04s remaining: 479ms 162: learn: 0.1788436 total: 2.05s remaining: 465ms 163: learn: 0.1780870 total: 2.06s remaining: 451ms 164: learn: 0.1778217 total: 2.06s remaining: 438ms 165: learn: 0.1774635 total: 2.08s remaining: 425ms 166: learn: 0.1766113 total: 2.1s remaining: 415ms 167: learn: 0.1753497 total: 2.12s remaining: 403ms 168: learn: 0.1740266 total: 2.13s remaining: 392ms 169: learn: 0.1731058 total: 2.15s remaining: 380ms 170: learn: 0.1723178 total: 2.16s remaining: 367ms 171: learn: 0.1715993 total: 2.17s remaining: 354ms 172: learn: 0.1704719 total: 2.18s remaining: 340ms 173: learn: 0.1694361 total: 2.19s remaining: 327ms 174: learn: 0.1688269 total: 2.2s remaining: 314ms 175: learn: 0.1682591 total: 2.2s remaining: 301ms 176: learn: 0.1673707 total: 2.22s remaining: 288ms 177: learn: 0.1671943 total: 2.24s remaining: 277ms 178: learn: 0.1666458 total: 2.26s remaining: 265ms 179: learn: 0.1660139 total: 2.28s remaining: 253ms 180: learn: 0.1652719 total: 2.3s remaining: 242ms 181: learn: 0.1643594 total: 2.32s remaining: 229ms 182: learn: 0.1635202 total: 2.33s remaining: 216ms 183: learn: 0.1627135 total: 2.34s remaining: 203ms 184: learn: 0.1620158 total: 2.35s remaining: 190ms 185: learn: 0.1615713 total: 2.35s remaining: 177ms 186: learn: 0.1606615 total: 2.36s remaining: 164ms 187: learn: 0.1597244 total: 2.37s remaining: 151ms 188: learn: 0.1590019 total: 2.38s remaining: 138ms 189: learn: 0.1585646 total: 2.39s remaining: 126ms 190: learn: 0.1578091 total: 2.39s remaining: 113ms 191: learn: 0.1570803 total: 2.4s remaining: 100ms 192: learn: 0.1561039 total: 2.41s remaining: 87.4ms 193: learn: 0.1554807 total: 2.42s remaining: 74.8ms 194: learn: 0.1540806 total: 2.43s remaining: 62.2ms 195: learn: 0.1528199 total: 2.43s remaining: 49.7ms 196: learn: 0.1519209 total: 2.44s remaining: 37.2ms 197: learn: 0.1513105 total: 2.45s remaining: 24.7ms 198: learn: 0.1508391 total: 2.46s remaining: 12.4ms 199: learn: 0.1496336 total: 2.47s remaining: 0us
y_pred= catb_tuned.predict(x_test)
accuracy_score(y_test,y_pred)
0.7489177489177489
feature= pd.Series(catb_tuned.feature_importances_,
index=x_train.columns).sort_values(ascending=False)
sns.barplot(x=feature, y=feature.index)
plt.xlabel('Değişken Önem Skorlarrı')
plt.ylabel('Değişkenler')
plt.title('Değişken Önem Düzeyleri')
plt.show()
modeller =[
knn_tuned,
loj_model,
svm_tuned,
mlpc_tuned,
cart_tuned,
rf_tuned,
gbm_tuned,
catb_tuned,
lgbm_tuned,
xgb_tuned]
sonuc= []
sonuclar = pd.DataFrame(columns=["Modeller", "Accuracy"])
for model in modeller:
isimler = model.__class__.__name__
y_pred = model.predict(x_test)
dogruluk = accuracy_score(y_test, y_pred)
sonuc = pd.DataFrame([[isimler, dogruluk * 100]], columns=["Modeller", "Accuracy"])
sonuclar = pd.concat([sonuclar, sonuc], ignore_index=True)
C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but KNeighborsClassifier was fitted with feature names warnings.warn( C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but LogisticRegression was fitted with feature names warnings.warn( C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but SVC was fitted with feature names warnings.warn( C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but DecisionTreeClassifier was fitted with feature names warnings.warn( C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but RandomForestClassifier was fitted with feature names warnings.warn( C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\base.py:464: UserWarning: X does not have valid feature names, but GradientBoostingClassifier was fitted with feature names warnings.warn(
sonuclar = sonuclar.sort_values(by='Accuracy', ascending=False)
sns.barplot(x='Accuracy',y='Modeller',data= sonuclar, color="r")
plt.xlabel('Accuracy %')
plt.title('Modellerin Doğruluk Oranları');
sonuclar
| Modeller | Accuracy | |
|---|---|---|
| 1 | LogisticRegression | 76.623377 |
| 9 | XGBClassifier | 76.190476 |
| 4 | DecisionTreeClassifier | 75.757576 |
| 8 | LGBMClassifier | 75.757576 |
| 7 | CatBoostClassifier | 74.891775 |
| 2 | SVC | 74.458874 |
| 5 | RandomForestClassifier | 74.025974 |
| 0 | KNeighborsClassifier | 73.160173 |
| 3 | MLPClassifier | 72.727273 |
| 6 | GradientBoostingClassifier | 65.367965 |
yüksek korelasyonu sahip değişkenler den bazıları çıkarılır çünkü benzer şeyler açıklamaktadırlar
?gbm_model
# Logistic Regression
loj_model = LogisticRegression(solver="liblinear").fit(x,y)
# K-EN Yakın Komşu
knn_model= KNeighborsClassifier().fit(x_train,y_train)
knn_params= {"n_neighbors":np.arange(1,50)}
# Support Vector Machines (SVM)
svm_model= SVC(kernel= "linear").fit(x_train,y_train)
svm_params= {"C":np.arange(1,5),
"kernel":["linear","rbf"]}
# Artificial neural networks
scaler= StandardScaler()
scaler.fit(x_train)
x_train= scaler.transform(x_train)
scaler.fit(x_test)
x_test= scaler.transform(x_test)
mlpc_model= MLPClassifier().fit(x_train,y_train)
mlpc_params= {"hidden_layer_sizes":[(10,10),(100,100,100),(100,100),(3,5)],
"alpha":[1,5,0.1,0.01,0.03,0.05,0.0001]}
mlpc= MLPClassifier(solver="lbfgs",activation= "logistic") # sınıflandırma problemlerinde activationu logistic yapmamız gerekiyor
# CART
cart_model= DecisionTreeClassifier().fit(x_train,y_train)
cart_params= {"max_depth": [1,3,5,8,10],
"min_samples_split":[2,3,5,10,20,50]}
# Random Forest
rf_model= RandomForestClassifier().fit(x_train,y_train)
rf_params= {"n_estimators":[100,200,500,1000],
"max_features":[3,5,7,8],
"min_samples_split": [2,5,10,20]}
# Gradient Boosting Machines (GBM)
gbm_model= GradientBoostingClassifier().fit(x_train,y_train)
gbm_params= {"learning_rate":[0.1,0.01,0.001,0.05],
"n_estimators":[100,300,500,1000],
"max_depth":[2,3,5,8]}
# XGBoost
xgb_model= XGBClassifier().fit(x_train,y_train)
xgb_params= {"n_estimators":[100,500,1000],
"subsample":[0.6,0.8,1],
"max_depth":[3,5,7],
"learning_rate":[0.1,0.001,0.01]}
# Light GBM
lgbm_model= LGBMClassifier().fit(x_train,y_train)
lgbm_params= {"learnin_rate":[0.001,0.01,0.01],
"n_estimators":[200,500,100],
"max_depth":[1,2,35,8]}
# Category Boosting (CatBoost)
catb_model= CatBoostClassifier().fit(x_train,y_train,verbose=False)
catb_params= {"iterations":[200,500,1000],
"learning_rate": [0.01,0.03,0.1],
"depth": [4,5,8]}
C:\Users\mehdi\anaconda3\Lib\site-packages\sklearn\neural_network\_multilayer_perceptron.py:691: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet. warnings.warn(
[LightGBM] [Info] Number of positive: 188, number of negative: 349 [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.000341 seconds. You can set `force_col_wise=true` to remove the overhead. [LightGBM] [Info] Total Bins 611 [LightGBM] [Info] Number of data points in the train set: 537, number of used features: 8 [LightGBM] [Info] [binary:BoostFromScore]: pavg=0.350093 -> initscore=-0.618630 [LightGBM] [Info] Start training from score -0.618630 [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf [LightGBM] [Warning] No further splits with positive gain, best gain: -inf